package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.exception.CustomException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.quality.QualityProblemFeedback;
import com.ruoyi.system.mapper.QualityProblemFeedbackMapper;
import com.ruoyi.system.service.IQualityProblemFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author GE-LV5
 * @create 2023/2/25 21:29
 * 问题反馈
 */
@Service
public class QualityProblemFeedbackServiceImpl extends ServiceImpl<QualityProblemFeedbackMapper, QualityProblemFeedback> implements IQualityProblemFeedbackService {

    @Autowired
    QualityProblemFeedbackMapper qualityProblemFeedbackMapper;

    /**
     * 查询所有问题反馈
     *
     * @param dept 问题反馈
     * @return
     */
    @Override
    public List<QualityProblemFeedback> selectQualityProblemFeedbackList(QualityProblemFeedback dept) {
        return qualityProblemFeedbackMapper.selectQualityProblemFeedback(dept);
    }

    /**
     * 根据id去删除
     *
     * @param id
     * @return
     */
    @Override
    public int deleteQualityProblemFeedbackById(Long id) {
        return qualityProblemFeedbackMapper.deleteQualityProblemFeedbackById(id);
    }


    /**
     * 新增问题反馈
     *
     * @param ordersCustomer 问题反馈
     * @return
     */
    @Override
    @Transactional
    public int insertQualityProblemFeedback(QualityProblemFeedback ordersCustomer) {
        if (StringUtils.isNull(ordersCustomer)) {
            throw new CustomException("添加失败！");
        }
        ordersCustomer.setCreateTime(DateUtils.getNowDate());
        ordersCustomer.setCreateBy(SecurityUtils.getUsername());
        return qualityProblemFeedbackMapper.insertQualityProblemFeedback(ordersCustomer);
    }

    /**
     * 修改问题反馈
     *
     * @param ordersManual 问题反馈
     */
    @Override
    @Transactional
    public int updateQualityProblemFeedback(QualityProblemFeedback ordersManual) {
        ordersManual.setUpdateTime(DateUtils.getNowDate());
        ordersManual.setUpdateBy(SecurityUtils.getUsername());
        return qualityProblemFeedbackMapper.updateQualityProblemFeedback(ordersManual);
    }

}
